function AddCRM_Code() {
	var buffer = new StringBuffer();
	buffer.append('<div id="addcrm" class="addapp hidden">');
		buffer.append('<div id="menu9" class="line border-bottom hidden"><div class="icon"><img src="img/customer.png"/></div><div class="name">客户</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="9"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu30" class="line border-bottom hidden"><div class="icon"><img src="img/customersearch.png"/></div><div class="name">客户查重</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="30"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu31" class="line border-bottom hidden"><div class="icon"><img src="img/customernear.png"/></div><div class="name">附近客户</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="31"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu32" class="line border-bottom hidden"><div class="icon"><img src="img/highsea.png"/></div><div class="name">公海客户</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="32"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu33" class="line border-bottom hidden"><div class="icon"><img src="img/goal.png"/></div><div class="name">销售目标</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="33"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu10" class="line border-bottom hidden"><div class="icon"><img src="img/contacts.png"/></div><div class="name">联系人</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="10"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu12" class="line border-bottom hidden"><div class="icon"><img src="img/order.png"/></div><div class="name">订单</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="12"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu13" class="line border-bottom hidden"><div class="icon"><img src="img/contract.png"/></div><div class="name">合同</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="13"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu11" class="line border-bottom hidden"><div class="icon"><img src="img/product.png"/></div><div class="name">产品</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="11"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu16" class="line border-bottom hidden"><div class="icon"><img src="img/library.png"/></div><div class="name">库存</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="16"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu34" class="line border-bottom hidden"><div class="icon"><img src="img/purchase.png"/></div><div class="name">采购管理</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="34"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu35" class="line border-bottom hidden"><div class="icon"><img src="img/movement.png"/></div><div class="name">调拨</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="35"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu23" class="line border-bottom hidden"><div class="icon"><img src="img/librarys.png"/></div><div class="name">库位</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="23"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu17" class="line border-bottom hidden"><div class="icon"><img src="img/supplier.png"/></div><div class="name">供应商</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="17"><div class="mui-switch-handle"></div></div></div></div>');
	buffer.append('</div>');
	return buffer.toString();
};

function Init_AddCRM(){
	addcrm.find(".mui-switch").each(function(i,info){
		if(User && User.CRM_Menu && User.CRM_Menu.indexOf(","+$(info).attr("val")+",")>-1)
		{
			$(info).addClass("mui-active");
		}
	});

	if(User)
	{
		addcrm.find(".line").attr("class","line border-bottom hidden");
		if(User.RolePower){
			var powers = User.RolePower.split(",");
			$.each(powers, function(i,info) {
				if(info!="")
				{
					addcrm.find("#menu"+info).removeClass("hidden");
				}
			});
		}
	}
	mui("#addcrm").on("toggle",".mui-switch",function(event){
		var data={};
		if(event.detail.isActive){
		    data.state="open";
		}else{
		    data.state="close";
		}
		data.act = "Set_CRM_Menu";
		data.userid=userid;
		data.comid=comid;
		data.source=source;
		data.itemid=$(this).attr("val");
		data.sign=GetSign(data.act);
		
		mui.getJSON(index_domain, data, function(json) {
			var ids = CRM.ListVal($("#addcrm .mui-active"));
			User.CRM_Menu=","+ids+",";
			if(data.state=="close")
			{
				User.Often_Menu=User.Often_Menu.replace(","+data.itemid+",",",");
			}
			
			plus.storage.setItem("crm_user",JSON.stringify(User));
			setTimeout(function(){
				$("#contentlist0").html(CRMPanel_Code());
				Init_CRMPanel(".allapp");
			},1000);
			$("#often"+data.itemid).hide();
		});
		
	});
};


function AddOA_Code() {
	var buffer = new StringBuffer();
	buffer.append('<div id="addoa" class="addapp hidden">');
		buffer.append('<div id="menu1" class="line border-bottom hidden"><div class="icon"><img src="img/share.png"/></div><div class="name">分享</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="1"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu2" class="line border-bottom hidden"><div class="icon"><img src="img/daily.png"/></div><div class="name">日志</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="2"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu3" class="line border-bottom hidden"><div class="icon"><img src="img/task.png"/></div><div class="name">任务</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="3"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu4" class="line border-bottom hidden"><div class="icon"><img src="img/examine.png"/></div><div class="name">审批</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="4"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu37" class="line border-bottom hidden"><div class="icon"><img src="img/schedule.png"/></div><div class="name">日程</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="37"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu25" class="line border-bottom hidden"><div class="icon"><img src="img/checkin2.png"/></div><div class="name">打卡记录</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="25"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu7" class="line border-bottom hidden"><div class="icon"><img src="img/checkset.png"/></div><div class="name">打卡设置</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="7"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu36" class="line border-bottom hidden"><div class="icon"><img src="img/waiqin.png"/></div><div class="name">外勤签到</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="36"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu27" class="line border-bottom hidden"><div class="icon"><img src="img/checkreport.png"/></div><div class="name">打卡报表</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="27"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu21" class="line border-bottom hidden"><div class="icon"><img src="img/notebook.png"/></div><div class="name">记事本</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="21"><div class="mui-switch-handle"></div></div></div></div>');
	buffer.append('</div>');
	return buffer.toString();
};


function Init_AddOA(){
	addoa.find(".mui-switch").each(function(i,info){
		if(User && User.OA_Menu && User.OA_Menu.indexOf(","+$(info).attr("val")+",")>-1)
		{
			$(info).addClass("mui-active");
		}
	});

	if(User)
	{
		addoa.find(".line").attr("class","line border-bottom hidden");
		if(User.RolePower){
			var powers = User.RolePower.split(",");
			$.each(powers, function(i,info) {
				if(info!="")
				{
					addoa.find("#menu"+info).removeClass("hidden");
				}
			});
		}
	}
	mui("#addoa").on("toggle",".mui-switch",function(event){
		var data={};
		if(event.detail.isActive){
		    data.state="open";
		}else{
		    data.state="close";
		}
		data.act = "Set_OA_Menu";
		data.userid=userid;
		data.comid=comid;
		data.source=source;
		data.itemid=$(this).attr("val");
		data.sign=GetSign(data.act);
		
		mui.getJSON(index_domain, data, function(json) {
			var ids = CRM.ListVal($("#addoa .mui-active"));
			User.OA_Menu=","+ids+",";
			if(data.state=="close")
			{
				User.Often_Menu=User.Often_Menu.replace(","+data.itemid+",",",");
			}
			plus.storage.setItem("crm_user",JSON.stringify(User));
			setTimeout(function(){
				$("#contentlist0").html(OAPanel_Code());
				Init_OAPanel(".allapp");
			},1000);
			
			
			$("#often"+data.itemid).hide();
		});
		
	});
};

function AddHR_Code() {
	var buffer = new StringBuffer();
	buffer.append('<div id="addhr" class="addapp hidden">');
		buffer.append('<div id="menu28" class="line border-bottom hidden"><div class="icon"><img src="img/users.png"/></div><div class="name">员工管理</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="28"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu29" class="line border-bottom hidden"><div class="icon"><img src="img/depart.png"/></div><div class="name">组织架构</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="29"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu38" class="line border-bottom hidden"><div class="icon"><img src="img/salary.png"/></div><div class="name">薪资管理</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="38"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu39" class="line border-bottom hidden"><div class="icon"><img src="img/agreement.png"/></div><div class="name">员工合同</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="39"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu40" class="line border-bottom hidden"><div class="icon"><img src="img/security.png"/></div><div class="name">员工社保</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="40"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu41" class="line border-bottom hidden"><div class="icon"><img src="img/securityset.png"/></div><div class="name">社保设置</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="41"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu42" class="line border-bottom hidden"><div class="icon"><img src="img/birth.png"/></div><div class="name">员工生日</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="42"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu43" class="line border-bottom hidden"><div class="icon"><img src="img/zhaopin.png"/></div><div class="name">招聘管理</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="43"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu44" class="line border-bottom hidden"><div class="icon"><img src="img/jiang.png"/></div><div class="name">奖罚管理</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="44"><div class="mui-switch-handle"></div></div></div></div>');
		buffer.append('<div id="menu45" class="line border-bottom hidden"><div class="icon"><img src="img/fagongzi.png"/></div><div class="name">发工资</div><div class="onoff"><div class="mui-switch mui-switch-mini" val="45"><div class="mui-switch-handle"></div></div></div></div>');
	buffer.append('</div>');
	return buffer.toString();
};


function Init_AddHR(){
	addhr.find(".mui-switch").each(function(i,info){
		if(User && User.HR_Menu && User.HR_Menu.indexOf(","+$(info).attr("val")+",")>-1)
		{
			$(info).addClass("mui-active");
		}
	});

	if(User)
	{
		addhr.find(".line").attr("class","line border-bottom hidden");
		if(User.RolePower){
			var powers = User.RolePower.split(",");
			$.each(powers, function(i,info) {
				if(info!="")
				{
					addhr.find("#menu"+info).removeClass("hidden");
				}
			});
		}
	}
	mui("#addhr").on("toggle",".mui-switch",function(event){
		var data={};
		if(event.detail.isActive){
		    data.state="open";
		}else{
		    data.state="close";
		}
		data.act = "Set_HR_Menu";
		data.userid=userid;
		data.comid=comid;
		data.source=source;
		data.itemid=$(this).attr("val");
		data.sign=GetSign(data.act);
		
		mui.getJSON(index_domain, data, function(json) {
			var ids = CRM.ListVal($("#addhr .mui-active"));
			User.HR_Menu=","+ids+",";
			if(data.state=="close")
			{
				User.Often_Menu=User.Often_Menu.replace(","+data.itemid+",",",");
			}
			plus.storage.setItem("crm_user",JSON.stringify(User));
			setTimeout(function(){
				$("#contentlist0").html(HRPanel_Code());
				Init_HRPanel(".allapp");
			},1000);
			
			
			$("#often"+data.itemid).hide();
		});
		
	});
};